package com.sleep.psy.external_server.business.main.controller;


import com.alibaba.fastjson.JSON;
import com.sleep.psy.external_server.business.main.entity.vo.GetSchemeReq;
import com.sleep.psy.external_server.business.main.entity.vo.RegistReq;
import com.sleep.psy.external_server.business.main.service.MainUserSchemeService;
import com.sleep.psy.external_server.result.Result;
import com.sleep.psy.external_server.result.ResultEnum;
import com.sleep.psy.external_server.result.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 用户方案表 前端控制器
 * </p>
 *
 * @author wenliguo
 * @since 2025-08-12
 */
@Api(tags = "用户方案")
@RestController
@RequestMapping("/mainUserScheme")
public class MainUserSchemeController {

    protected Logger logger = LoggerFactory.getLogger(MainUserSchemeController.class);

    @Autowired
    private MainUserSchemeService userSchemeService;

    /**
     * 通过用户id和方案id获取量表、音频、视频
     * @author wenliguo
     * @date 2025/8/19 13:41
     * @param req 请求
     * @return com.sleep.psy.external_server.result.Result<java.lang.Long>
    */
    @PostMapping("/selectUserScheme")
    @ApiOperation(value = "通过用户id和方案id获取量表、音频、视频")
    public Result<Long> selectUserScheme(@Valid @RequestBody GetSchemeReq req) {

        logger.info("通过用户id和方案id获取量表、音频、视频参数:{}", JSON.toJSONString(req));
        try {
            return userSchemeService.selectUserScheme(req);
        } catch (Exception e) {
            logger.error("通过用户id和方案id获取量表、音频、视频出错", e);
            return ResultUtil.error(ResultEnum.SERVER_INTERNAL_ERROR);
        }
    }
}

